﻿/// <reference path="jquery.js" />
/// <reference path="common.js" />
        var booltype1 = false;
var sethref = '';
function ajax_new(href, a_type, route) {
	
	
    var type = a_type,
            sth = href;
	var st=getCookie("from")!="null"?24:0;
    var html = tpljs.find("#" + href).html(),
            r_winh = $(window).height()-st-2;
   			r_html = $(".html-box");
	
	$(window).scrollTop(0);
	
    $("body").attr("class", href);
    if(html!=undefined){
    	r_html.html("<div class='js-body' style='min-height:" + r_winh + "px'>" + html + "</div>");
		setlange_obj();
    }else{
    	var tim1 = setInterval(function () {
	        $.showLoading();
	        clearInterval(tim1);
	    }, 500);
		href="/APP/" +href.replace("-",".")
		if(href.indexOf("?")!=-1){
			href+="?"+Math.random()
		}else{
			href+="?"+localStorage.getItem("")+Math.random()
		}
		
	    $.ajax({
	        url: href,
	        type: "get",
	        timeout : 7000, 
	        dataType: "html",
	        cache:true,
	        success: function (html) {	            
	            clearInterval(tim1);
	            $.hideLoading();
	            r_html.html("<div class='js-body' style='min-height:" + r_winh + "px'>" + html + "</div>");
	            setlange_obj();
	        },
	        error: function () {
	            clearInterval(tim1);
	            $.hideLoading();
	             $.modal({
		          title: "tips",
		          text: "Loading error",
		          buttons: [
		            { text: "Return", onClick: function(){
		            	window.history.go(-1)
		            } }
		          ]
		       });	            
	        }
	    });
    }
    
     //判断安卓返回键
   if(navigator.userAgent.match(/Html5Plus/i)) {
	    plus.key.removeEventListener("backbutton", android_p1);
	    plus.key.removeEventListener("backbutton", android_p2);
	   // alert(href)
	    if (href.indexOf('root-html')!=-1) {
	        plus.key.addEventListener("backbutton", android_p1);
	    } else {
	        plus.key.addEventListener("backbutton", android_p2)
	    }
    }
   
};

function android_p1(){
	//alert(1)
	var wss1 = plus.webview.currentWebview().opener();
		wss1.close();
}
function android_p2(){
	//alert(2)
	window.history.go(-1);
}


